package com.project.controller;

import com.project.bean.ReplayBean;
import com.project.bean.UserBean;
import com.project.service.IReplayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

@RestController
@RequestMapping("replay")
public class ReplayController {
    @Autowired
    private IReplayService service;
    @RequestMapping("add")
    public String add(@Valid ReplayBean replay, HttpServletRequest req){

       UserBean loginUser= (UserBean) req.getSession().getAttribute("loginUser");
       replay.setUserId(loginUser.getId());
       service.add(replay);
        return "ok";
    }
}
